<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pay extends CI_Controller {
	
	var $logged = FALSE;
	var $value = '';
	
	public function __construct(){
		parent::__construct ();
		//if($this->session->userdata('loggedin')) $this->logged=TRUE;
	}
	
	public function index()
	{
		$this->lang->load('site', get_lang());
		$data['page'] = 'pages/pay';
		$this->load->view('mainview', $data);
	}
	
	public function payd()
	{
		
		foreach ($_POST as $key => $value) {
			//$value = urlencode(stripslashes($value));
			//$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
			//$req = "&$key=$value";
			$this->value .= $key.": ".$value.";\n ";
		}
		//$this->value = substr($this->value, 0, 200) ;
		//echo "<pre>".$this->value."<pre>"; 
		//exit;
		
		/*$data = array(
			'status' => $_POST['payment_status'],
			'details' => $this->value,
			'project' => $_POST['item-number']
		);*/
		
		$data = array(
			'cd_project' => $this->input->post('item_number'),
			'nm_status' => $this->input->post('payment_status'),
			'txn_id' => $this->input->post('txn_id'),
			'ds_details' => $this->value
		);
				
		$this->load->model('Payments');		
		$this->Payments->update($data);
	}
}